<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<ui:composition xmlns="http://www.w3.org/1999/xhtml"
                xmlns:ui="http://java.sun.com/jsf/facelets"
                xmlns:h="http://java.sun.com/jsf/html"
                xmlns:f="http://java.sun.com/jsf/core"
                template="/templates/mainLayout.xhtml">
    <ui:define name="menu">
        <style type="text/css">
            .colStyle1 {
                vertical-align: top;
                width: 30%;
            }
            .colStyle2 {
                vertical-align: top;
            }
        </style>
        <nav class="vertical menu">
            <ul>
                <ui:repeat value="#{categoryBean.categoryList}" var="category">
                    <h:panelGroup rendered="#{category.devices.size() > 0 ? (category.devices.contains(session.getAttribute('DEVICE'))) : true}">
                        <li>
                            <a style="background: lightyellow; font-weight: bold; color: hotpink;" href="#{request.contextPath}/category/#{category.id}/#{category.url}">
                            #{category.name}
                            </a>
                        </li>
                        <ui:repeat value="#{categoryBean.getHotCategories(category)}" var="child">
                            <a href="#{request.contextPath}/category/#{child.id}/#{child.url}">+   #{child.name}</a>
                        </ui:repeat>
                        <ui:repeat value="#{itemBean.getHotItems(category)}" var="item">
                            <h:panelGroup rendered="#{item.devices.size() > 0 ? (item.devices.contains(session.getAttribute('DEVICE'))) : true}">
                                <a href="#{request.contextPath}/item/#{item.id}/#{item.url}">
                                    <h:panelGrid columns="2" columnClasses="colStyle1, colStyle2">
                                        <h:graphicImage style="width: 58px;" value="#{item.thumbnailURL}" alt="#{item.name}"
                                                        rendered="#{item.thumbnailURL != null and item.thumbnailURL.length() > 0}"/>
                                        <h:outputText value="#{item.introduction}" escape="false"/>
                                    </h:panelGrid>
                                </a>
                            </h:panelGroup>
                        </ui:repeat>
                        <h:panelGroup>
                            <a style="color: darkviolet;" href="#{request.contextPath}/category/#{category.id}/#{category.url}">
                                Xem thêm >>
                            </a>
                        </h:panelGroup>
                    </h:panelGroup>
                </ui:repeat>
            </ul>
        </nav>
    </ui:define>
    <ui:define name="content">
        <div class="content">
            <ui:repeat value="#{categoryBean.itemList}" var="item">
                <h:panelGroup rendered="#{item.devices.size() > 0 ? (item.devices.contains(session.getAttribute('DEVICE'))) : true}">
                    <article class="underline">
                        <h:panelGroup rendered="#{item.thumbnailURL != null and item.thumbnailURL.length() > 0}">
                            <div class="post-preview">
                                <a href="#{request.contextPath}/item/#{item.id}/#{item.url}">
                                    <h:graphicImage value="#{item.thumbnailURL}" alt="#{item.name}"/>
                                </a>
                            </div>
                        </h:panelGroup>
                        <div class="post-content">
                            <h2><a href="#{request.contextPath}/item/#{item.id}/#{item.url}">#{item.name}</a></h2>
                            <h:panelGroup rendered="#{item.introduction != null}">
                                <p><h:outputText value="#{item.introduction}" escape="false"/></p>
                            </h:panelGroup>
                            <!-- <div class="date"><span>20 mar 2012</span></div> -->
                        </div>
                        <div class="clear"></div>
                    </article>
                </h:panelGroup>
            </ui:repeat>
        </div>
    </ui:define>
</ui:composition>